define(function () {
    'use strict';

    function ctrl($scope,$stateParams,$ionicHistory,InfoService, WebService, CommonService) {

        $scope.prod_id = $stateParams["prod_id"];
        $scope.econtract_type = $stateParams["econtract_type"];


        $scope.$on('$ionicView.loaded', function() {
            init();
        });

        function init(){
            if($scope.prod_id && $scope.prod_id.length > 0) {
                $scope.type = 1; //读boss
                InfoService.getProdFiles($scope.prod_id).then(function(data){
                    if(data && data.length > 0){
                        $scope.agreementList = data;
                    }
                });
            } else {
                $scope.type = 2; //读ifs
                WebService.getEncontractList($scope.econtract_type).then(
                function (data){
                    if(data && data.length > 0){
                        $scope.agreementList = data;
                    }
                });
            }
        }

        $scope.closeAgreementList = function(){
            $ionicHistory.goBack();
        };
    }

    ctrl.$inject = ['$scope','$stateParams','$ionicHistory','InfoService', 'WebService', 'CommonService'];
    return ctrl;
});
